using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Microsoft.Extensions.DependencyInjection;

namespace JW.Framework.IOC.Attributes
{
    /// <summary>
    /// 使用本属性修饰的类，在程序集注入时会自动注入
    /// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false, Inherited = false)]
    public sealed class AutoInjectAttribute : Attribute
    {
        public AutoInjectAttribute()
            : this(ServiceLifetime.Scoped)
        {
        }

        public AutoInjectAttribute(ServiceLifetime lifetime)
        {
            this.Lifetime = lifetime;
        }

        /// <summary>
        /// 生命周期
        /// </summary>
        public ServiceLifetime Lifetime { get; set; }

        /// <summary>
        /// 当前修饰类或接口的子类或实现类，默认类型为当前修饰类型本身
        /// </summary>
        public Type ImplementType { get; set; }

        /// <summary>
        /// 实现类型的字符串描述, 格式: Namespace.TypeName,AssemblyName
        /// </summary>
        public string StrImplementType { get; set; }
    }
}
